from header_common import *
from ID_animations import *
from header_mission_templates import *
from header_tableau_materials import *
from header_items import *
from module_constants import *

####################################################################################################################
#  Each tableau material contains the following fields:
#  1) Tableau id (string): used for referencing tableaux in other files. The prefix tab_ is automatically added before each tableau-id.
#  2) Tableau flags (int). See header_tableau_materials.py for a list of available flags
#  3) Tableau sample material name (string).
#  4) Tableau width (int).
#  5) Tableau height (int).
#  6) Tableau mesh min x (int): divided by 1000 and used when a mesh is auto-generated using the tableau material
#  7) Tableau mesh min y (int): divided by 1000 and used when a mesh is auto-generated using the tableau material
#  8) Tableau mesh max x (int): divided by 1000 and used when a mesh is auto-generated using the tableau material
#  9) Tableau mesh max y (int): divided by 1000 and used when a mesh is auto-generated using the tableau material
#  10) Operations block (list): A list of operations. See header_operations.py for reference.
#     The operations block is executed when the tableau is activated.
# 
####################################################################################################################

#banner height = 200, width = 85 with wood, 75 without wood

tableaus = [

("game_character_sheet", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 266, 532,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4287137928),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_camera_parameters, 0, 40, 40, 0, 100000),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (position_set_x, pos1, -20),
    (position_set_y, pos1, -20),
    (cur_tableau_add_tableau_mesh, "tableau_troop_character_color", ":var_0", 1, 0, 0),
    (position_set_z, pos1, 200),
    (cur_tableau_add_tableau_mesh, "tableau_troop_character_alpha_mask", ":var_0", 1, 0, 0),
    (position_set_z, pos1, 300),
]),

("game_inventory_window", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 180, 270,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4287137928),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_camera_parameters, 0, 40, 40, 0, 100000),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (position_set_x, pos1, -20),
    (position_set_y, pos1, -20),
    (cur_tableau_add_tableau_mesh, "tableau_troop_inventory_color", ":var_0", 1, 0, 0),
    (position_set_z, pos1, 200),
    (cur_tableau_add_tableau_mesh, "tableau_troop_inventory_alpha_mask", ":var_0", 1, 0, 0),
    (position_set_z, pos1, 300),
]),

("game_profile_window", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 320, 480,
[
    (store_script_param, ":var_0", 1),
    (assign, ":var_1", ":var_0"),
    (val_mod, ":var_1", 2),
    (try_begin),
        (eq, ":var_1", 0),
        (assign, ":var_2", "trp_multiplayer_profile_troop_male"),
    (else_try),
        (assign, ":var_2", "trp_multiplayer_profile_troop_female"),
    (try_end),
    (troop_set_face_key_from_current_profile, ":var_2"),
    (cur_tableau_set_background_color, 4287137928),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_camera_parameters, 0, 40, 40, 0, 100000),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (position_set_x, pos1, -20),
    (position_set_y, pos1, -20),
    (cur_tableau_add_tableau_mesh, "tableau_troop_profile_color", ":var_2", 1, 0, 0),
    (position_set_z, pos1, 200),
    (cur_tableau_add_tableau_mesh, "tableau_troop_profile_alpha_mask", ":var_2", 1, 0, 0),
]),

("game_party_window", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 300, 300,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4287137928),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_camera_parameters, 0, 40, 40, 0, 100000),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (position_set_x, pos1, -20),
    (position_set_y, pos1, -20),
    (cur_tableau_add_tableau_mesh, "tableau_troop_party_color", ":var_0", 1, 0, 0),
    (position_set_z, pos1, 200),
    (cur_tableau_add_tableau_mesh, "tableau_troop_party_alpha_mask", ":var_0", 1, 0, 0),
    (position_set_z, pos1, 300),
]),

("game_troop_label_banner", 0, "tableau_with_transparency", 256, 256, -128, 0, 128, 256,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4287137928),
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_camera_parameters, 0, 100, 100, 0, 100000),
    (init_position, pos1),
    (position_set_y, pos1, 120),
    (cur_tableau_add_mesh, ":var_0", 1, 120, 0),
]),

("round_shield_1", 0, "sample_shield_round_1", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 125),
    (cur_tableau_add_mesh, ":var_0", 1, 120, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_round_1", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 100, 0, 100000),
]),

("round_shield_2", 0, "sample_shield_matte", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 120),
    (cur_tableau_add_mesh, ":var_0", 1, 116, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_round_2", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 100, 0, 100000),
]),

("round_shield_3", 0, "sample_shield_matte", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 120),
    (cur_tableau_add_mesh, ":var_0", 1, 116, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_round_3", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 100, 0, 100000),
]),

("round_shield_4", 0, "sample_shield_matte", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 125),
    (cur_tableau_add_mesh, ":var_0", 1, 123, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_round_4", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 100, 0, 100000),
]),

("round_shield_5", 0, "sample_shield_matte", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 125),
    (cur_tableau_add_mesh, ":var_0", 1, 122, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_round_5", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 100, 0, 100000),
]),

("small_round_shield_1", 0, "sample_shield_small_round_1", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 130),
    (cur_tableau_add_mesh, ":var_0", 1, 127, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_small_round_1", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 100, 0, 100000),
]),

("small_round_shield_2", 0, "sample_shield_small_round_2", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 130),
    (cur_tableau_add_mesh, ":var_0", 1, 127, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_small_round_2", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 100, 0, 100000),
]),

("small_round_shield_3", 0, "sample_shield_matte", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 130),
    (cur_tableau_add_mesh, ":var_0", 1, 127, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_small_round_3", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 100, 0, 100000),
]),

("kite_shield_1", 0, "sample_shield_matte", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -60),
    (position_set_y, pos1, 140),
    (cur_tableau_add_mesh, ":var_0", 1, 116, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_kite_1", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("kite_shield_2", 0, "sample_shield_matte", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -57),
    (position_set_y, pos1, 140),
    (cur_tableau_add_mesh, ":var_0", 1, 116, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_kite_2", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("kite_shield_3", 0, "sample_shield_matte", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -57),
    (position_set_y, pos1, 140),
    (cur_tableau_add_mesh, ":var_0", 1, 116, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_kite_3", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("kite_shield_4", 0, "sample_shield_matte", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 160),
    (cur_tableau_add_mesh, ":var_0", 1, 120, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_kite_4", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("heater_shield_1", 0, "sample_shield_matte", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -60),
    (position_set_y, pos1, 151),
    (cur_tableau_add_mesh, ":var_0", 1, 116, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_heater_1", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("heater_shield_2", 0, "sample_shield_matte", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -50),
    (position_set_y, pos1, 150),
    (cur_tableau_add_mesh, ":var_0", 1, 116, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_heater_2", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("pavise_shield_1", 0, "sample_shield_matte", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -54),
    (position_set_y, pos1, 120),
    (cur_tableau_add_mesh, ":var_0", 1, 118, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_pavise_1", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("pavise_shield_2", 0, "sample_shield_matte", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (position_set_x, pos1, -54),
    (position_set_y, pos1, 120),
    (cur_tableau_add_mesh, ":var_0", 1, 116, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_shield_pavise_2", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("heraldic_armor_a", 0, "sample_heraldic_armor_a", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (store_sub, ":var_1", ":var_0", "mesh_arms_a01"),
    (troop_get_slot, ":var_2", "trp_banner_background_color_array", ":var_1"),
    (cur_tableau_set_background_color, ":var_2"),
    (init_position, pos1),
    (cur_tableau_add_mesh_with_vertex_color, "mesh_heraldic_armor_bg", 1, 200, 100, ":var_2"),
    (init_position, pos1),
    (position_set_z, pos1, 50),
    (position_set_x, pos1, -25),
    (position_set_y, pos1, 130),
    (cur_tableau_add_mesh, ":var_0", 1, 103, 0),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_heraldic_armor_a", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("heraldic_armor_b", 0, "sample_heraldic_armor_b", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (store_sub, ":var_1", ":var_0", "mesh_arms_a01"),
    (troop_get_slot, ":var_2", "trp_banner_background_color_array", ":var_1"),
    (cur_tableau_set_background_color, ":var_2"),
    (init_position, pos1),
    (cur_tableau_add_mesh_with_vertex_color, "mesh_heraldic_armor_bg", 1, 200, 100, ":var_2"),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (position_set_x, pos1, -5),
    (position_set_y, pos1, 130),
    (cur_tableau_add_mesh, ":var_0", 1, 113, 0),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_heraldic_armor_b", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("heraldic_armor_c", 0, "sample_heraldic_armor_c", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (store_sub, ":var_1", ":var_0", "mesh_arms_a01"),
    (troop_get_slot, ":var_2", "trp_banner_background_color_array", ":var_1"),
    (cur_tableau_set_background_color, ":var_2"),
    (init_position, pos1),
    (cur_tableau_add_mesh_with_vertex_color, "mesh_heraldic_armor_bg", 1, 200, 100, ":var_2"),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (position_set_x, pos1, 0),
    (position_set_y, pos1, 130),
    (cur_tableau_add_mesh, ":var_0", 1, 115, 0),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_heraldic_armor_c", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("heraldic_armor_d", 0, "sample_heraldic_armor_d", 512, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (store_sub, ":var_1", ":var_0", "mesh_arms_a01"),
    (troop_get_slot, ":var_2", "trp_banner_background_color_array", ":var_1"),
    (cur_tableau_set_background_color, ":var_2"),
    (init_position, pos1),
    (cur_tableau_add_mesh_with_vertex_color, "mesh_heraldic_armor_bg", 1, 200, 100, ":var_2"),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (position_set_x, pos1, 0),
    (position_set_y, pos1, 130),
    (cur_tableau_add_mesh, ":var_0", 1, 113, 0),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_heraldic_armor_d", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("plate_harness_heraldic", 0, "sample_platemail_banner", 1024, 1024, 0, 0, 0, 0,
[
    (store_script_param_1, ":var_0"),
    (call_script, "script_troop_get_banner_mesh", ":var_0"),
    (assign, ":var_1", reg1),
    (set_fixed_point_multiplier, 100),
    (try_begin),
        (ge, ":var_0", 0),
        (troop_slot_eq, ":var_0", slot_troop_banner_scene_prop, -1),
        (troop_get_slot, ":var_2", ":var_0", slot_troop_custom_banner_bg_color_1),
        (cur_tableau_set_background_color, ":var_2"),
        (init_position, pos1),
        (call_script, "script_draw_banner_to_region", ":var_0", -8, -44, 10000, 10000, 2200, 2200, 5000, 10000, 1),
    (else_try),
        (store_sub, ":var_3", ":var_1", "mesh_arms_a01"),
        (troop_get_slot, ":var_4", "trp_banner_background_color_array", ":var_3"),
        (cur_tableau_set_background_color, ":var_4"),
        (init_position, pos1),
        (init_position, pos1),
        (position_set_z, pos1, 50),
        (position_set_x, pos1, -8),
        (position_set_y, pos1, -9),
        (cur_tableau_add_mesh, ":var_1", 1, 40, 0),
    (try_end),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (try_begin),
        (neg|ge, ":var_0", 0),
        (cur_tableau_add_mesh, "mesh_tableau_mesh_platemail", 1, 0, 0),
    (else_try),
        (eq, ":var_0", 0),
        (troop_slot_eq, ":var_0", slot_troop_banner_scene_prop, 0),
        (cur_tableau_add_mesh, "mesh_tableau_mesh_platemail", 1, 0, 0),
    (else_try),
        (cur_tableau_add_mesh, "mesh_tableau_mesh_platemail_banner", 1, 0, 0),
    (try_end),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("platemail_harness_heraldic", 0, "sample_platemail_banner", 1024, 1024, 0, 0, 0, 0,
[
    (store_script_param_1, ":var_0"),
    (call_script, "script_troop_get_banner_mesh", ":var_0"),
    (assign, ":var_1", reg1),
    (set_fixed_point_multiplier, 100),
    (try_begin),
        (ge, ":var_0", 0),
        (troop_slot_eq, ":var_0", slot_troop_banner_scene_prop, -1),
        (troop_get_slot, ":var_2", ":var_0", slot_troop_custom_banner_bg_color_1),
        (cur_tableau_set_background_color, ":var_2"),
        (init_position, pos1),
        (call_script, "script_draw_banner_to_region", ":var_0", 65, -50, 10000, 10000, 2500, 2500, 5000, 10000, 1),
    (else_try),
        (store_sub, ":var_3", ":var_1", "mesh_arms_a01"),
        (troop_get_slot, ":var_4", "trp_banner_background_color_array", ":var_3"),
        (cur_tableau_set_background_color, ":var_4"),
        (init_position, pos1),
        (position_set_z, pos1, 50),
        (position_set_x, pos1, 65),
        (position_set_y, pos1, -9),
        (cur_tableau_add_mesh, ":var_1", 1, 40, 0),
    (try_end),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (try_begin),
        (neg|ge, ":var_0", 0),
        (cur_tableau_add_mesh, "mesh_tableau_mesh_platemail", 1, 0, 0),
    (else_try),
        (eq, ":var_0", 0),
        (troop_slot_eq, ":var_0", slot_troop_banner_scene_prop, 0),
        (cur_tableau_add_mesh, "mesh_tableau_mesh_platemail", 1, 0, 0),
    (else_try),
        (cur_tableau_add_mesh, "mesh_tableau_mesh_platemail_banner", 1, 0, 0),
    (try_end),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("early_transitional_heraldic", 0, "sample_early_transitional_heraldic_banner", 1024, 1024, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (store_sub, ":var_1", ":var_0", "mesh_arms_a01"),
    (troop_get_slot, ":var_2", "trp_banner_background_color_array", ":var_1"),
    (cur_tableau_set_background_color, ":var_2"),
    (init_position, pos1),
    (cur_tableau_add_mesh_with_vertex_color, "mesh_heraldic_armor_bg", 1, 200, 100, ":var_2"),
    (init_position, pos1),
    (position_set_x, pos1, 17),
    (position_set_y, pos1, 150),
    (cur_tableau_add_mesh, ":var_0", 1, 90, 0),
    (init_position, pos1),
    (position_set_z, pos1, 30),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_early_transitional_heraldic_banner", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 200, 200, 0, 100000),
]),

("troop_note_alpha_mask", 0, "mat_troop_portrait_mask", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 8947848),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (cur_tableau_render_as_alpha_mask),
    (call_script, "script_add_troop_to_cur_tableau", ":var_0"),
]),

("troop_note_color", 0, "mat_troop_portrait_color", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4291214228),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (call_script, "script_add_troop_to_cur_tableau", ":var_0"),
]),

("troop_character_alpha_mask", 0, "mat_troop_portrait_mask", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 8947848),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (cur_tableau_render_as_alpha_mask),
    (call_script, "script_add_troop_to_cur_tableau_for_character", ":var_0"),
]),

("troop_character_color", 0, "mat_troop_portrait_color", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4292923313),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (call_script, "script_add_troop_to_cur_tableau_for_character", ":var_0"),
]),

("troop_inventory_alpha_mask", 0, "mat_troop_portrait_mask", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 8947848),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (cur_tableau_render_as_alpha_mask),
    (call_script, "script_add_troop_to_cur_tableau_for_inventory", ":var_0"),
]),

("troop_inventory_color", 0, "mat_troop_portrait_color", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4285159482),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (call_script, "script_add_troop_to_cur_tableau_for_inventory", ":var_0"),
]),

("troop_profile_alpha_mask", 0, "mat_troop_portrait_mask", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 8947848),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (cur_tableau_render_as_alpha_mask),
    (call_script, "script_add_troop_to_cur_tableau_for_profile", ":var_0"),
]),

("troop_profile_color", 0, "mat_troop_portrait_color", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4294567848),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (call_script, "script_add_troop_to_cur_tableau_for_profile", ":var_0"),
]),

("troop_party_alpha_mask", 0, "mat_troop_portrait_mask", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 8947848),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (cur_tableau_render_as_alpha_mask),
    (call_script, "script_add_troop_to_cur_tableau_for_party", ":var_0"),
]),

("troop_party_color", 0, "mat_troop_portrait_color", 1024, 1024, 0, 0, 400, 400,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4290681970),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (call_script, "script_add_troop_to_cur_tableau_for_party", ":var_0"),
]),

("troop_note_mesh", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 350, 350,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4287137928),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_camera_parameters, 0, 40, 40, 0, 100000),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (position_set_x, pos1, -20),
    (position_set_y, pos1, -20),
    (cur_tableau_add_tableau_mesh, "tableau_troop_note_color", ":var_0", 1, 0, 0),
    (position_set_z, pos1, 200),
    (cur_tableau_add_tableau_mesh, "tableau_troop_note_alpha_mask", ":var_0", 1, 0, 0),
    (position_set_z, pos1, 300),
    (cur_tableau_add_mesh, "mesh_portrait_blend_out", 1, 0, 0),
]),

("center_note_mesh", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 200, 200,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_background_color, 8947848),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (init_position, pos8),
    (position_set_x, pos8, -210),
    (position_set_y, pos8, 200),
    (position_set_z, pos8, 300),
    (cur_tableau_add_point_light, 8, 550, 500, 450),
    (cur_tableau_set_camera_parameters, 1, 10, 10, 10, 10000),
    (init_position, pos1),
    (position_set_z, pos1, 0),
    (position_set_z, pos1, -500),
    (init_position, pos1),
    (position_set_y, pos1, -100),
    (position_set_x, pos1, -100),
    (position_set_z, pos1, 100),
    (position_rotate_z, pos1, 200),
    (party_get_icon, ":var_1", ":var_0"),
    (try_begin),
        (ge, ":var_1", 0),
        (cur_tableau_add_map_icon, ":var_1", 1, 0),
    (try_end),
    (init_position, pos5),
    (position_set_x, pos5, -90),
    (position_set_z, pos5, 500),
    (position_set_y, pos5, 480),
    (position_rotate_x, pos5, -90),
    (position_rotate_z, pos5, 180),
    (position_rotate_x, pos5, -35),
    (cur_tableau_set_camera_position, 5),
]),

("faction_note_mesh_for_menu", 0, "pic_arms_swadian", 1024, 512, 0, 0, 450, 225,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4294967295),
    (set_fixed_point_multiplier, 100),
    (try_begin),
        (is_between, ":var_0", "fac_kingdom_1", "fac_kingdoms_end"),
        (store_add, ":var_1", "mesh_pic_arms_swadian", ":var_0"),
        (val_sub, ":var_1", "fac_kingdom_1"),
        (init_position, pos1),
        (position_set_y, pos1, -5),
        (position_set_x, pos1, -45),
        (cur_tableau_add_mesh, ":var_1", 1, 0, 0),
        (cur_tableau_set_camera_parameters, 0, 160, 80, 0, 100000),
    (try_end),
]),

("faction_note_mesh", 0, "pic_arms_swadian", 1024, 512, 0, 0, 500, 250,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4294967295),
    (set_fixed_point_multiplier, 100),
    (try_begin),
        (is_between, ":var_0", "fac_kingdom_1", "fac_kingdoms_end"),
        (store_add, ":var_1", "mesh_pic_arms_swadian", ":var_0"),
        (val_sub, ":var_1", "fac_kingdom_1"),
        (init_position, pos1),
        (position_set_y, pos1, -5),
        (cur_tableau_add_mesh, ":var_1", 1, 0, 0),
        (cur_tableau_set_camera_parameters, 0, 100, 50, 0, 100000),
    (try_end),
]),

("faction_note_mesh_banner", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 200, 200,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (try_begin),
        (faction_get_slot, ":var_1", ":var_0", slot_faction_leader),
        (ge, ":var_1", 0),
        (troop_get_slot, ":var_2", ":var_1", slot_troop_banner_scene_prop),
        (store_add, ":var_3", "spr_banner_f21", 1),
        (is_between, ":var_2", "spr_banner_a", ":var_3"),
        (val_sub, ":var_2", "spr_banner_a"),
        (store_add, ":var_4", ":var_2", "mesh_banner_a01"),
        (init_position, pos1),
        (position_set_y, pos1, 100),
        (cur_tableau_add_mesh, ":var_4", 1, 0, 0),
        (cur_tableau_set_camera_parameters, 0, 210, 210, 0, 100000),
    (try_end),
]),

("2_factions_mesh", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 200, 200,
[
    (store_script_param, ":var_0", 1),
    (store_mod, ":var_1", ":var_0", 128),
    (val_div, ":var_0", 128),
    (val_add, ":var_0", "fac_player_supporters_faction"),
    (val_add, ":var_1", "fac_player_supporters_faction"),
    (set_fixed_point_multiplier, 100),
    (try_begin),
        (faction_get_slot, ":var_2", ":var_0", slot_faction_leader),
        (ge, ":var_2", 0),
        (troop_get_slot, ":var_3", ":var_2", slot_troop_banner_scene_prop),
        (store_add, ":var_4", "spr_banner_f21", 1),
        (is_between, ":var_3", "spr_banner_a", ":var_4"),
        (val_sub, ":var_3", "spr_banner_a"),
        (store_add, ":var_5", ":var_3", "mesh_banner_a01"),
        (init_position, pos1),
        (position_set_x, pos1, -50),
        (position_set_y, pos1, 100),
        (cur_tableau_add_mesh, ":var_5", 1, 0, 0),
    (try_end),
    (try_begin),
        (faction_get_slot, ":var_2", ":var_1", slot_faction_leader),
        (ge, ":var_2", 0),
        (troop_get_slot, ":var_3", ":var_2", slot_troop_banner_scene_prop),
        (store_add, ":var_4", "spr_banner_f21", 1),
        (is_between, ":var_3", "spr_banner_a", ":var_4"),
        (val_sub, ":var_3", "spr_banner_a"),
        (store_add, ":var_5", ":var_3", "mesh_banner_a01"),
        (init_position, pos1),
        (position_set_x, pos1, 50),
        (position_set_y, pos1, 100),
        (cur_tableau_add_mesh, ":var_5", 1, 0, 0),
    (try_end),
    (cur_tableau_set_camera_parameters, 0, 210, 210, 0, 100000),
]),

("color_picker", 0, "missiles", 32, 32, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (init_position, pos1),
    (cur_tableau_add_mesh, "mesh_color_picker", 1, 0, 0),
    (position_move_z, pos1, 1),
    (position_move_x, pos1, -2),
    (position_move_y, pos1, -2),
    (cur_tableau_add_mesh_with_vertex_color, "mesh_white_plane", 1, 200, 0, ":var_0"),
    (cur_tableau_set_camera_parameters, 0, 20, 20, 0, 100000),
]),

("custom_banner_square_no_mesh", 0, "missiles", 512, 512, 0, 0, 300, 300,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (call_script, "script_draw_banner_to_region", ":var_0", 0, 0, 10000, 10000, 9800, 9800, 10000, 10000, 0),
    (cur_tableau_set_camera_parameters, 0, 100, 100, 0, 100000),
]),

("custom_banner_default", 0, "missiles", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (call_script, "script_draw_banner_to_region", ":var_0", -9, -2, 7450, 19400, 7200, 18000, 9000, 10000, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_custom_banner", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 100, 200, 0, 100000),
]),

("custom_banner_tall", 0, "missiles", 512, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (call_script, "script_draw_banner_to_region", ":var_0", -9, 12, 8250, 18000, 8000, 21000, 10000, 10000, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_custom_banner", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 100, 200, 0, 100000),
]),

("custom_banner_square", 0, "missiles", 256, 256, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (call_script, "script_draw_banner_to_region", ":var_0", -11, 10, 7700, 7700, 7500, 7500, 8300, 10000, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_custom_banner_square", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 100, 100, 0, 100000),
]),

("custom_banner_short", 0, "missiles", 256, 512, 0, 0, 0, 0,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (call_script, "script_draw_banner_to_region", ":var_0", -10, 0, 8050, 5000, 4200, 4800, 6600, 10000, 0),
    (init_position, pos1),
    (position_set_z, pos1, 10),
    (cur_tableau_add_mesh, "mesh_tableau_mesh_custom_banner_short", 1, 0, 0),
    (cur_tableau_set_camera_parameters, 0, 100, 50, 0, 100000),
]),

("background_selection", 0, "missiles", 512, 512, 0, 0, 100, 100,
[
    (store_script_param, ":var_0", 1),
    (troop_get_slot, ":var_1", "trp_player", slot_troop_custom_banner_bg_type),
    (troop_set_slot, "trp_player", slot_troop_custom_banner_bg_type, ":var_0"),
    (set_fixed_point_multiplier, 100),
    (call_script, "script_draw_banner_to_region", "trp_player", 0, 0, 10000, 10000, 9800, 9800, 10000, 10000, 0),
    (cur_tableau_set_camera_parameters, 0, 100, 100, 0, 100000),
    (troop_set_slot, "trp_player", slot_troop_custom_banner_bg_type, ":var_1"),
]),

("positioning_selection", 0, "missiles", 512, 512, 0, 0, 100, 100,
[
    (store_script_param, ":var_0", 1),
    (troop_get_slot, ":var_1", "trp_player", slot_troop_custom_banner_positioning),
    (troop_set_slot, "trp_player", slot_troop_custom_banner_positioning, ":var_0"),
    (set_fixed_point_multiplier, 100),
    (call_script, "script_draw_banner_to_region", "trp_player", 0, 0, 10000, 10000, 9800, 9800, 10000, 10000, 0),
    (cur_tableau_set_camera_parameters, 0, 100, 100, 0, 100000),
    (troop_set_slot, "trp_player", slot_troop_custom_banner_positioning, ":var_1"),
]),

("achievement_troop", 0, "troop_portrait", 1024, 1024, 0, 0, 600, 600,
[
    (store_script_param, ":var_0", 1),
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_background_color, 0),
    (cur_tableau_set_ambient_light, 100, 100, 100),
    (init_position, pos8),
    (position_set_x, pos8, -210),
    (position_set_y, pos8, 200),
    (position_set_z, pos8, 300),
    (cur_tableau_add_point_light, 8, 550, 500, 450),
    (cur_tableau_set_override_flags, 511),
    (troop_get_type, ":var_1", "trp_player"),
    (try_begin),
        (eq, ":var_0", 0),
        (try_begin),
            (ge, ":var_1", 1),
            (cur_tableau_add_override_item, "itm_pl_443"),
        (try_end),
        (cur_tableau_add_override_item, "itm_hide_boots"),
        (cur_tableau_add_override_item, "itm_two_handed_battle_axe_2"),
        (assign, ":var_2", "anim_pose_cheer_1"),
    (else_try),
        (eq, ":var_0", 1),
        (cur_tableau_add_override_item, "itm_pop_noldor_capt_helm"),
        (try_begin),
            (ge, ":var_1", 1),
            (cur_tableau_add_override_item, "itm_pop_noldor_female_armor"),
        (else_try),
            (cur_tableau_add_override_item, "itm_pop_noldor_ranger_garb"),
        (try_end),
        (cur_tableau_add_override_item, "itm_pop_noldor_boots"),
        (cur_tableau_add_override_item, "itm_pop_noldor_longsword"),
        (assign, ":var_2", "anim_pose_cheer_1"),
    (else_try),
        (eq, ":var_0", 2),
        (cur_tableau_add_override_item, "itm_pop_noldor_knight_helm"),
        (cur_tableau_add_override_item, "itm_pop_noldor_rune_armor"),
        (cur_tableau_add_override_item, "itm_mail_boots"),
        (cur_tableau_add_override_item, "itm_gauntlets"),
        (cur_tableau_add_override_item, "itm_pop_noldor_runesword"),
        (assign, ":var_2", "anim_pose_cheer_2"),
    (else_try),
        (eq, ":var_0", 3),
        (cur_tableau_add_override_item, "itm_pl_447"),
        (cur_tableau_add_override_item, "itm_pl_111"),
        (cur_tableau_add_override_item, "itm_splinted_greaves"),
        (cur_tableau_add_override_item, "itm_scale_gauntlets"),
        (cur_tableau_add_override_item, "itm_strange_great_sword"),
        (assign, ":var_2", "anim_pose_4"),
    (else_try),
        (eq, ":var_0", 4),
        (cur_tableau_add_override_item, "itm_pl_554"),
        (cur_tableau_add_override_item, "itm_pop_royal_platemail"),
        (cur_tableau_add_override_item, "itm_pl_490"),
        (cur_tableau_add_override_item, "itm_gauntlets"),
        (cur_tableau_add_override_item, "itm_pop_knight_war_axe"),
        (assign, ":var_2", "anim_pose_4"),
    (else_try),
        (eq, ":var_0", 5),
        (cur_tableau_add_override_item, "itm_pop_jatu_noble_armor"),
        (cur_tableau_add_override_item, "itm_pl_487"),
        (cur_tableau_add_override_item, "itm_gauntlets"),
        (cur_tableau_add_override_item, "itm_pop_noldor_longsword"),
        (assign, ":var_2", "anim_pose_3"),
    (else_try),
        (eq, ":var_0", 6),
        (assign, ":var_2", "anim_pose_3"),
        (cur_tableau_add_override_item, "itm_pop_shadow_legion_armor"),
        (cur_tableau_add_override_item, "itm_pl_489"),
        (cur_tableau_add_override_item, "itm_gauntlets"),
        (cur_tableau_add_override_item, "itm_pop_empire_broadsword"),
    (else_try),
        (eq, ":var_0", 7),
        (cur_tableau_add_override_item, "itm_pop_dark_chain_armor"),
        (cur_tableau_add_override_item, "itm_leather_boots"),
        (cur_tableau_add_override_item, "itm_leather_gloves"),
        (cur_tableau_add_override_item, "itm_two_handed_axe"),
        (assign, ":var_2", "anim_pose_cheer_2"),
    (else_try),
        (eq, ":var_0", 8),
        (cur_tableau_add_override_item, "itm_pop_anaconda_plate"),
        (cur_tableau_add_override_item, "itm_pl_488"),
        (cur_tableau_add_override_item, "itm_mail_mittens"),
        (cur_tableau_add_override_item, "itm_war_spear"),
        (assign, ":var_2", "anim_pose_cheer_1"),
    (else_try),
        (eq, ":var_0", 9),
        (cur_tableau_add_override_item, "itm_pop_jatu_raider_armor"),
        (cur_tableau_add_override_item, "itm_pl_486"),
        (cur_tableau_add_override_item, "itm_scale_gauntlets"),
        (cur_tableau_add_override_item, "itm_strange_sword"),
        (assign, ":var_2", "anim_pose_cheer_1"),
    (else_try),
        (eq, ":var_0", 10),
        (cur_tableau_add_override_item, "itm_pop_demonskin"),
        (cur_tableau_add_override_item, "itm_black_greaves"),
        (cur_tableau_add_override_item, "itm_gauntlets"),
        (cur_tableau_add_override_item, "itm_morningstar"),
        (assign, ":var_2", "anim_pose_cheer_2"),
    (else_try),
        (eq, ":var_0", 11),
        (cur_tableau_add_override_item, "itm_arena_tunic_green"),
        (cur_tableau_add_override_item, "itm_hide_boots"),
        (assign, ":var_2", "anim_pose_fists_up"),
    (else_try),
        (eq, ":var_0", 12),
        (cur_tableau_add_override_item, "itm_arena_armor_red"),
        (cur_tableau_add_override_item, "itm_hide_boots"),
        (assign, ":var_2", "anim_pose_fists_up"),
    (else_try),
        (eq, ":var_0", 13),
        (try_begin),
            (eq, ":var_1", 1),
            (cur_tableau_add_override_item, "itm_pop_valk_stag_plate"),
        (else_try),
            (cur_tableau_add_override_item, "itm_pl_452"),
        (try_end),
        (cur_tableau_add_override_item, "itm_pl_490"),
        (cur_tableau_add_override_item, "itm_gauntlets"),
        (cur_tableau_add_override_item, "itm_morningstar"),
        (assign, ":var_2", "anim_pose_1"),
    (else_try),
        (eq, ":var_0", 14),
        (cur_tableau_add_override_item, "itm_pl_552"),
        (cur_tableau_add_override_item, "itm_pl_134"),
        (cur_tableau_add_override_item, "itm_pl_490"),
        (cur_tableau_add_override_item, "itm_mail_mittens"),
        (cur_tableau_add_override_item, "itm_bastard_sword_b"),
        (assign, ":var_2", "anim_pose_1"),
    (else_try),
        (eq, ":var_0", 15),
        (cur_tableau_add_override_item, "itm_pop_dawn_plate"),
        (cur_tableau_add_override_item, "itm_pl_490"),
        (cur_tableau_add_override_item, "itm_gauntlets"),
        (cur_tableau_add_override_item, "itm_pop_claymore"),
        (assign, ":var_2", "anim_pose_2"),
    (else_try),
        (eq, ":var_0", 16),
        (cur_tableau_add_override_item, "itm_royal_crown"),
        (cur_tableau_add_override_item, "itm_pl_508"),
        (cur_tableau_add_override_item, "itm_black_greaves"),
        (cur_tableau_add_override_item, "itm_gauntlets"),
        (assign, ":var_2", "anim_pose_3"),
    (else_try),
        (eq, ":var_0", 17),
        (try_begin),
            (eq, ":var_1", 1),
            (cur_tableau_add_override_item, "itm_pop_sing_temptress_armor"),
        (else_try),
            (cur_tableau_add_override_item, "itm_pl_277"),
            (cur_tableau_add_override_item, "itm_leather_gloves"),
        (try_end),
        (cur_tableau_add_override_item, "itm_pl_486"),
        (assign, ":var_2", "anim_pose_5"),
    (else_try),
        (eq, ":var_0", 18),
        (try_begin),
            (eq, ":var_1", 1),
            (cur_tableau_add_override_item, "itm_pl_442"),
        (else_try),
            (cur_tableau_add_override_item, "itm_pl_251"),
        (try_end),
        (cur_tableau_add_override_item, "itm_woolen_hose"),
        (assign, ":var_2", "anim_pose_1"),
    (else_try),
        (eq, ":var_0", 19),
        (cur_tableau_add_override_item, "itm_pl_259"),
        (cur_tableau_add_override_item, "itm_light_leather_boots"),
        (assign, ":var_2", "anim_pose_running"),
    (else_try),
        (eq, ":var_0", 20),
        (try_begin),
            (eq, ":var_1", 1),
            (cur_tableau_add_override_item, "itm_headcloth"),
            (cur_tableau_add_override_item, "itm_dress"),
        (else_try),
            (cur_tableau_add_override_item, "itm_felt_hat"),
            (cur_tableau_add_override_item, "itm_coarse_tunic"),
        (try_end),
        (cur_tableau_add_override_item, "itm_wrapping_boots"),
        (assign, ":var_2", "anim_pose_fail"),
    (else_try),
        (eq, ":var_0", 21),
        (cur_tableau_add_override_item, "itm_woolen_dress"),
        (assign, ":var_2", "anim_pose_scratchass"),
    (else_try),
        (eq, ":var_0", 22),
        (cur_tableau_add_override_item, "itm_leather_jacket"),
        (cur_tableau_add_override_item, "itm_hide_boots"),
        (cur_tableau_add_override_item, "itm_sword_medieval_c"),
        (assign, ":var_2", "anim_pose_5"),
    (else_try),
        (eq, ":var_0", 23),
        (cur_tableau_add_override_item, "itm_ragged_outfit"),
        (cur_tableau_add_override_item, "itm_hunter_boots"),
        (cur_tableau_add_override_item, "itm_butchering_knife"),
        (assign, ":var_2", "anim_pose_2"),
    (else_try),
        (eq, ":var_0", 24),
        (assign, ":var_2", "anim_pose_ashamed"),
    (else_try),
        (eq, ":var_0", 25),
        (troop_get_slot, ":var_3", "trp_player", 162),
        (try_for_range, ":var_4", 5, 8),
            (troop_get_inventory_slot, ":var_5", ":var_3", ":var_4"),
            (try_begin),
                (ge, ":var_5", 0),
                (cur_tableau_add_override_item, ":var_5"),
            (try_end),
        (try_end),
        (assign, ":var_2", "anim_pose_3"),
    (else_try),
        (eq, ":var_0", 100),
        (assign, ":var_6", 526),
        (cur_tableau_set_override_flags, ":var_6"),
        (assign, ":var_2", "anim_pose_4"),
    (else_try),
        (eq, ":var_0", 101),
        (faction_get_slot, ":var_7", "$g_notification_menu_var1", 68),
        (try_for_range, ":var_4", 5, 8),
            (troop_get_inventory_slot, ":var_5", ":var_7", ":var_4"),
            (try_begin),
                (ge, ":var_5", 0),
                (cur_tableau_add_override_item, ":var_5"),
            (try_end),
        (try_end),
        (assign, ":var_2", "anim_pose_4"),
    (else_try),
        (assign, ":var_2", "anim_pose_scratchass"),
    (try_end),
    (init_position, pos2),
    (cur_tableau_set_camera_parameters, 1, 6, 6, 10, 10000),
    (init_position, pos5),
    (position_set_z, pos5, 96),
    (position_set_y, pos5, 350),
    (try_begin),
        (eq, ":var_0", 101),
        (party_get_slot, ":var_8", "$g_notification_menu_var2", slot_town_lord),
        (cur_tableau_add_troop, ":var_8", 2, "anim_pose_4", 0),
    (else_try),
        (store_attribute_level, ":var_9", "trp_player", ca_strength),
        (troop_raise_attribute, "trp_player", ca_strength, 100),
        (cur_tableau_add_troop, "trp_player", 2, ":var_2", 0),
        (troop_raise_attribute, "trp_player", ca_strength, -1000),
        (troop_raise_attribute, "trp_player", ca_strength, ":var_9"),
    (try_end),
    (position_rotate_x, pos5, -90),
    (position_rotate_z, pos5, 180),
    (cur_tableau_set_camera_position, 5),
]),

("group_companions", 0, "troop_portrait", 1024, 1024, 0, 0, 1000, 1000,
[
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_background_color, 0),
    (cur_tableau_set_ambient_light, 100, 100, 100),
    (init_position, pos8),
    (position_set_x, pos8, -210),
    (position_set_y, pos8, 200),
    (position_set_z, pos8, 300),
    (cur_tableau_add_point_light, 8, 550, 500, 450),
    (cur_tableau_set_override_flags, 16),
    (cur_tableau_set_camera_parameters, 1, 9, 9, 10, 10000),
    (init_position, pos1),
    (position_set_x, pos1, 0),
    (position_set_y, pos1, 0),
    (position_set_z, pos1, 0),
    (troop_get_inventory_slot, ":var_0", "trp_player", 8),
    (try_begin),
        (gt, ":var_0", 0),
        (cur_tableau_add_horse, ":var_0", 1, "anim_horse_stand", 0),
        (cur_tableau_add_troop, "trp_player", 1, "anim_ride_0", 0),
    (else_try),
        (cur_tableau_add_troop, "trp_player", 1, "anim_pose_1", 0),
    (try_end),
    (party_get_num_companion_stacks, ":var_1", "p_main_party"),
    (val_min, ":var_1", 5),
    (try_for_range, ":var_2", 1, ":var_1"),
        (party_stack_get_troop_id, ":var_3", "p_main_party", ":var_2"),
        (try_begin),
            (is_between, ":var_3", "trp_npc_adonja", "trp_kingdom_1_lord"),
            (cur_tableau_set_override_flags, 16),
            (assign, ":var_4", 0),
        (else_try),
            (cur_tableau_set_override_flags, 0),
            (store_mul, ":var_4", ":var_3", 126233),
            (val_mod, ":var_4", 1000),
            (val_add, ":var_4", 1),
        (try_end),
        (store_mod, ":var_5", ":var_2", 2),
        (val_mul, ":var_5", 2),
        (val_sub, ":var_5", 1),
        (store_add, ":var_6", ":var_2", 1),
        (val_div, ":var_6", 2),
        (val_mul, ":var_6", 110),
        (val_mul, ":var_6", ":var_5"),
        (init_position, pos2),
        (position_set_x, pos2, ":var_6"),
        (position_set_y, pos2, -100),
        (troop_get_inventory_slot, ":var_0", ":var_3", 8),
        (try_begin),
            (gt, ":var_0", 0),
            (cur_tableau_add_horse, ":var_0", 2, "anim_horse_stand", 0),
            (cur_tableau_add_troop, ":var_3", 2, "anim_ride_0", ":var_4"),
        (else_try),
            (cur_tableau_add_troop, ":var_3", 2, "anim_stand_man", ":var_4"),
        (try_end),
    (try_end),
    (init_position, pos6),
    (position_set_z, pos6, 260),
    (position_set_y, pos6, 600),
    (position_rotate_x, pos6, -80),
    (position_rotate_z, pos6, 180),
    (cur_tableau_set_camera_position, 6),
    (copy_position, pos7, pos6),
    (position_rotate_x, pos7, -90),
    (position_rotate_z, pos7, 30),
    (position_rotate_x, pos7, -60),
    (cur_tableau_add_sun_light, 7, 175, 150, 125),
]),

("retired_troop_alpha_mask", 0, "mat_troop_portrait_mask", 2048, 2048, 0, 0, 600, 600,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 8947848),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (cur_tableau_render_as_alpha_mask),
    (call_script, "script_add_troop_to_cur_tableau_for_retirement", ":var_0"),
]),

("retired_troop_color", 0, "mat_troop_portrait_color", 2048, 2048, 0, 0, 600, 600,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4293383065),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (call_script, "script_add_troop_to_cur_tableau_for_retirement", ":var_0"),
]),

("retirement_troop", 0, "tableau_with_transparency", 2048, 2048, 0, 0, 600, 600,
[
    (store_script_param, ":var_0", 1),
    (cur_tableau_set_background_color, 4287137928),
    (cur_tableau_set_ambient_light, 10, 11, 15),
    (set_fixed_point_multiplier, 100),
    (cur_tableau_set_camera_parameters, 0, 40, 40, 0, 100000),
    (init_position, pos1),
    (position_set_z, pos1, 100),
    (position_set_x, pos1, -20),
    (position_set_y, pos1, -20),
    (cur_tableau_add_tableau_mesh, "tableau_retired_troop_color", ":var_0", 1, 0, 0),
    (position_set_z, pos1, 200),
    (cur_tableau_add_tableau_mesh, "tableau_retired_troop_alpha_mask", ":var_0", 1, 0, 0),
]),


]